import { defineStore } from "pinia";
import type { IHttpProxy, IStudio } from '@shared/constans/types/configType'


enum SizeType {
    small = "small",
    XSmall = "x-small",
    Default = "default",
    Large = "large",
    XLarge = "x-large",
}

enum DensityType {
    Compact = "compact",
    Comfortable = "comfortable",
    Default = "default",
}

interface AppState {
    darkTheme: boolean;
    SidebarSize: SizeType;
    SidebarDensity: DensityType;
    lang: string;
    http_proxy: IHttpProxy;
    system_config: IStudio;
}

export const useAppStore = defineStore("appConfig", {
    state: (): AppState => {
        return {
            darkTheme: true,
            SidebarSize: SizeType.small,
            SidebarDensity: DensityType.Compact,
            lang: "zhHans",
            http_proxy: {
                enable: false,
                host: "",
                port: ""
            },
            system_config: {
                server_name: "",
                server_url: "",
                username: "",
                password: "",
            }
        }
    },
    actions: {
        setDarkTheme(darkTheme: boolean) {
            this.darkTheme = darkTheme;
        },
        setSidebarSize(size: SizeType) {
            this.SidebarSize = size;
        },
        setSidebarDensity(density: DensityType) {
            this.SidebarDensity = density;
        },
        setLang(lang: string) {
            this.lang = lang;
        },
        setHttpProxy(proxy: IHttpProxy) {
            this.http_proxy = proxy;
        },
        setSystemConfig(config: IStudio) {
            this.system_config = config;
        },
    },
    getters: {
        getDarkTheme(): boolean {
            return this.darkTheme;
        },
        getSidebarSize(): SizeType {
            return this.SidebarSize;
        },
        getSidebarDensity(): DensityType {
            return this.SidebarDensity;
        },
        getLang(): string {
            return this.lang;
        },
        getHttpProxy(): IHttpProxy {
            return this.http_proxy;
        },
        getSystemConfig(): IStudio {
            return this.system_config;
        }
    }
})
